import java.io.File;
import java.io.FileInputStream;
import java.io.IOException;
import java.nio.ByteBuffer;
import java.nio.channels.FileChannel;

public class TestByteBuffer {
    public static void main(String[] args) {
        try(FileChannel channel = new FileInputStream("src/data.txtx").getChannel()){
            ByteBuffer buffer = ByteBuffer.allocate(10);
            

            while (true){
                int len = channel.read(buffer);
                if(len == -1){
                    break;
                }
                buffer.flip();
                while (buffer.hasRemaining()){
                    System.out.println((char) buffer.get());
                }
                buffer.clear();
            }


        } catch (IOException e){
            System.out.println(e);
        }
    }
}
